home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 11
/
CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso
/
cucd
/
programming
/
oberonv4
/
source
/
system
/
direlems.mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1996-06-02
|
4KB
|
106 lines
Syntax10.Scn.Fnt
StampElems
Alloc
2 Jun 96
Syntax10b.Scn.Fnt
FoldElems
MODULE DirElems; (** HM
(mah auto-update)*)
IMPORT Out, Viewers, Texts, TextFrames, Oberon, PopupElems, Directories, Display;
Elem* = POINTER TO ElemDesc;
ElemDesc* = RECORD (PopupElems.ElemDesc)
END ;
NotifyMsg = RECORD(Display.FrameMsg) END ;
Frame = POINTER TO RECORD(Display.FrameDesc) elem: Elem END ;
oldDirNotify: Directories.Notifier;
curDirName: ARRAY 32 OF CHAR;
PROCEDURE ReadName (t: Texts.Text; pos: LONGINT; VAR name: ARRAY OF CHAR);
VAR r: Texts.Reader; ch, stopch: CHAR; i: INTEGER; beg, end, time: LONGINT;
BEGIN
Texts.OpenReader(r, t, pos); Texts.Read(r, ch); i := 0;
IF ch = '"' THEN Texts.Read(r, ch);
WHILE ~r.eot & (ch # '"') DO name[i] := ch; INC(i); Texts.Read(r, ch) END
ELSE
WHILE ~r.eot & (ch > " ") DO name[i] := ch; INC(i); Texts.Read(r, ch) END
END ;
name[i] := 0X;
IF name = "^" THEN
Oberon.GetSelection(t, beg, end, time);
IF time >= 0 THEN ReadName(t, beg, name) END
END ReadName;
PROCEDURE SetDirName;
VAR i, j: INTEGER; name: ARRAY 256 OF CHAR; d, d0: Directories.Directory;
BEGIN
d := Directories.Current(); d0 := Directories.Startup();
Out.String("d : "); IF d#NIL THEN Out.String(d.path) ELSE Out.String("NIL!") END; Out.Ln;
Out.String("d0: "); IF d0#NIL THEN Out.String(d0.path) ELSE Out.String("NIL!") END; Out.Ln;
i := 0; WHILE (d0.path[i] # 0X) & (CAP(d0.path[i]) = CAP(d.path[i])) DO INC(i) END ;
IF (d0.path[i] = 0X) & ((d.path[i] = 0X) OR (d.path[i] = Directories.delimiter)) THEN
IF d.path[i] = Directories.delimiter THEN
name[0] := "$"; INC(i);
j := 0; REPEAT INC(j); name[j] := d.path[i]; INC(i) UNTIL name[j] = 0X
ELSE
name := "$";
END
ELSE
COPY(d.path, name)
END ;
i := 0; WHILE name[i] # 0X DO INC(i) END ;
IF i < 32 THEN COPY(name, curDirName)
ELSE curDirName[31] := 0X; j := 31;
REPEAT DEC(i); DEC(j); curDirName[j] := name[i] UNTIL j = 1;
curDirName[0] := "*"
END SetDirName;
PROCEDURE Exec (e: Elem; pos: LONGINT);
VAR msg: NotifyMsg; name: ARRAY 256 OF CHAR;
BEGIN ReadName(e.menu, pos, name); Directories.Change(name)
END Exec;
PROCEDURE DirNotify (op: INTEGER; path, name: ARRAY OF CHAR);
VAR msg: NotifyMsg;
BEGIN
IF op = Directories.change THEN SetDirName; Viewers.Broadcast (msg) END ;
oldDirNotify (op, path, name)
END DirNotify;
PROCEDURE HandleFrame(f: Display.Frame; VAR msg: Display.FrameMsg);
VAR m: TextFrames.UpdateMsg;
BEGIN
IF msg IS NotifyMsg THEN
WITH f: Frame DO
TextFrames.NotifyDisplay (Texts.ElemBase(f.elem), TextFrames.replace, Texts.ElemPos(f.elem), Texts.ElemPos(f.elem)+1)
END
END HandleFrame;
PROCEDURE Handle* (e: Texts.Elem; VAR m: Texts.ElemMsg);
VAR e1: Elem; f: Frame;
BEGIN
WITH e: Elem DO
COPY (curDirName, e.name);
WITH m: Texts.CopyMsg DO NEW(e1); m.e := e1; PopupElems.Handle(e, m)
| m: Texts.IdentifyMsg DO m.mod := "DirElems"; m.proc := "Alloc"
| m: PopupElems.ExecMsg DO Exec(e, m.pos)
| m: TextFrames.DisplayMsg DO
IF ~m.prepare THEN
NEW (f); f.X := m.X0; f.Y := m.Y0; f.W := 1; f.H := 1; (* trick (c) mah/cs *)
f.handle := HandleFrame; f.elem := e;
m.elemFrame := f
END ;
PopupElems.Handle (e, m)
ELSE PopupElems.Handle(e, m)
END
END Handle;
PROCEDURE Alloc*;
VAR e: Elem;
BEGIN
NEW(e); e.handle := Handle; Texts.new := e
END Alloc;
PROCEDURE Insert*;
VAR e: Elem; insert: TextFrames.InsertElemMsg;
BEGIN
NEW(e); e.handle := Handle; e.small := FALSE;
e.menu := TextFrames.Text(""); PopupElems.MeasureMenu(e);
insert.e := e; Viewers.Broadcast(insert)
END Insert;
BEGIN
SetDirName;
oldDirNotify := Directories.notify; Directories.notify := DirNotify
END DirElems.